<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //制作一个函数，getDayNum( 年月日日期 )，可以返回指定日
      // 期是当前年的第几天，getDayNum( “2019-1-2”)  返回值为：2

      function fn(a) {
        // var b = a.getFullYear();

        var one = new Date(a.getFullYear() + "-" + "1-1");
        a = a.getTime();
        one = one.getTime();
        var b = a - one;
        b = b / 1000 / 60 / 60 / 24;
        return `是当年的第${b+1}天`;
      }
      document.write(fn(new Date("2004-7-24")));
    </script>
  </body>
</html>
